<?php
	// 加载公共文件
	include_once('../public/config/config.php');
	include_once('../public/config/sql.php');

	// 实例化对象
	$obj = new sql($info);

	$key = isset($_POST['key']) ? $_POST['key'] : '';

	// 查询总条数
	$sql = "select count(*) AS aggregate from article";

	if(strlen($key) > 0){

		$sql .= " where concat(title,content) like ?";
	}

	$count = $obj->db_select_count($sql, $key);

	$maxPage = ceil($count / $pagesize);
	$page    = max($page, $minPage);
	$page    = min($page, $maxPage);
	$total   = ($page - 1) * $pagesize;

	// sql语句的拼接
	$sql = "select cid,id,img,title,slide,`describe`,content,state from article";

	if(strlen($key) > 0){

		$sql .=" where concat(title,content) like ?";
	}
	$sql .=" order by id desc limit ?,?";

	$articleList = $obj->db_select($sql, true, $key, $total, $pagesize);
?>